#include <iostream>
#include <sys/time.h>
#include <fstream>
#include <chrono>
#include <ctime>
#include <vector>
using namespace std;
using std::chrono::milliseconds;
vector<int> negr9(vector<int> a, string filename){
        bool negr11 = true;
    int k = a.size();
    while(negr11){
        negr11 = false;

        for(int i = 0 ; i<k-1;i++){
            if(a[i]>a[i+1]){
             
                swap(a[i],a[i+1]);
           
                negr11 = true;
            }
        }
         k--;


    }
    

    cout << endl;
    
    return a;


    
}
vector<int> negr10(string filename){
    vector<int> a;
    ifstream file;
    file.open(filename);
    string x;
    while(file.good()){
        getline(file,x);


        a.push_back(stoi(x));
    }
    // a = negr9(a);
    // cout << endl;
return a;
    
}
int main()
{
   namespace sc = chrono;

    vector<int> a;
    vector<string> filenames = {"m1_sorted.txt","m2_reverse.txt","m3_shuffle.txt"};

    for(int i = 0; i<3; i++){
        time_t now = time(nullptr);
        time_t end = time(nullptr);
    

       a = negr9(negr10(filenames[i]),filenames[i]);
      
       cout <<filenames[i]<<" "<< now-end <<"ms" << endl;
    }
    // negr9(negr10(filenames[1]),filenames[1]);

}





